<template>
  <view class="system-page">
    <Navbar
      title="系统设置"
    />

    <view class="menu-list">
      <view class="menu-item" @click="mygo('/pages/minePages/accountInfo')">
        <image
          class="menu-icon"
          src="/static/img/minePages/account-info.png"
          mode="widthFix"
        />
        <text class="menu-title">账号信息</text>
        <image
          class="menu-arrow"
          src="/static/img/minePages/mine-arrow.png"
          mode="widthFix"
        />
      </view>
      <view class="divider"></view>
      <view class="menu-item" @click="mygo('/pages/minePages/aboutUs')">
        <image
          class="menu-icon"
          src="/static/img/minePages/about-us.png"
          mode="widthFix"
        />
        <text class="menu-title">关于我们</text>
        <image
          class="menu-arrow"
          src="/static/img/minePages/mine-arrow.png"
          mode="widthFix"
        />
      </view>
    </view>

    <view class="logout-btn-wrap">
      <button class="logout-btn" @click="logout">退出登录</button>
    </view>
  </view>
</template>

<script setup>
import Navbar from '@/components/Navbar.vue';
import { mygo } from '@/utils/useNavigator';
import { useGlobalStore } from '@/store/app';
import { createRequest } from '@/utils/request';

const store = useGlobalStore();

const logout = async () => {
  try {
    // 调用登出接口
    await createRequest('/auth/logout', {
      method: 'post',
      data: {}
    });
  } catch (err) {
    console.error('登出接口调用失败:', err);
  }

  store.clearUserInfo();
  uni.showToast({ title: '退出登录', icon: 'none' });
  uni.reLaunch({
    url: '/pages/login'
  });
};
</script>

<style scoped lang="scss">
.system-page {
  @include page-with-header;
  min-height: 100vh;
  background: #172869;
  display: flex;
  flex-direction: column;
  position: relative;
}
.menu-list {
  margin: 40rpx 0 0 0;
  background: transparent;
}
.menu-item {
  display: flex;
  align-items: center;
  padding: 0 40rpx;
  height: 100rpx;
  color: #fff;
  font-size: 30rpx;
  background: transparent;
}
.menu-icon {
  width: 48rpx;
  margin-right: 24rpx;
}
.menu-title {
  flex: 1;
}
.menu-arrow {
  width: 14rpx;
}
.divider {
  height: 2rpx;
  background: #1a2e5a;
  margin: 0 40rpx;
}
.logout-btn-wrap {
  width: 100vw;
  position: fixed;
  left: 0;
  bottom: 60rpx;
  display: flex;
  justify-content: center;
  z-index: 10;
}
.logout-btn {
  width: 686rpx;
  height: 80rpx;
  background: linear-gradient(90deg, #3a8dde 0%, #256bda 100%);
  color: #fff;
  font-size: 32rpx;
  border: none;
  border-radius: 40rpx;
  box-shadow: 0 4rpx 16rpx rgba(58, 108, 255, 0.12);
  transition: all 0.3s ease;
  
  &:active {
    transform: scale(0.98);
  }
}
</style>
